{extend name='Common/index' /} {block name='content'}
<section class="content">
    <div class="box box-default">
        <div class="box-header with-border">
            <h3 class="box-title">{$info?'修改':'新增'}产品类型</h3>
        </div>
        <div class="box-body">
            <div class="form">
                <div class="form-group">
                    <label for="mark" class="col-sm-2 control-label">类型标识</label>
                    <div class="col-sm-10">
                        <input type="text" class="form-control" id="mark" name="mark" placeholder="请输入类型标识" value="{$info?$info['mark']:''}" autocomplete="off">
                        <input type="hidden" name="id" value="{$info?$info['id']:''}">
                    </div>
                </div>
                <div class="form-group">
                    <label for="title" class="col-sm-2 control-label">类型名称</label>
                    <div class="col-sm-10">
                        <input type="text" class="form-control" id="title" name="title" placeholder="请输入类型名称" value="{$info?$info['title']:''}" autocomplete="off">
                    </div>
                </div>
                <div class="form-group">
                    <label for="is_pro" class="col-sm-2 control-label">所属路由</label>
                    <div class="col-sm-10">
                        <select name="is_pro" class="form-control" multiple style="height: 250px;">
                          {foreach name="webroutes" item="v"}
                          <option value="{$v.id}" {$v['is_pro'] == $info['id']?'selected':''}>{$v.title}</option>
                          {/foreach}
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                        <button type="button" class="btn btn-primary sub">提交</button>
                        <a href="javascript:history.go(-1);" class="btn btn-default">返回</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>
{/block} {block name='js'}
<script src="__STATIC__/dist/js/formBasic.js"></script>
<script>
    $('.sub').click(function() {
        let names = document.querySelectorAll('.form-group > div > [name]'),
            vals = {};
        names = [].slice.call(names);
        names.map((e) => {
            vals[e.name] = $(e).val();
        });
        ajax('{:url("admin/Product/addtypeAuth")}', vals, 'post').then(e => {
            if (e.status === 200) {
                alert(e.msg);
                location.href = "{:url('admin/Product/type')}";
            } else {
                alert(e.msg);
            }
        });
    });
</script>
{/block}